package com.lailai.service.impl;

import com.lailai.constant.ErrorCode;
import com.lailai.exception.BusinessException;
import com.lailai.service.TestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author lgr
 * @Date 2025/9/16
 * @Description 测试服务实现类
 * @Email 983105834@qq.com
 */
@Service
public class TestAppServiceImpl implements TestService {
    private static final Logger logger = LoggerFactory.getLogger(TestAppServiceImpl.class);

    @Autowired
    private MetadataExtServiceImpl metadataExtService;

    public List<String> test() {
        try {
            List<String> list = metadataExtService.betchGetSchema("routes").get("routes");
            logger.info("测试appService:{}", list);
            return list;
        } catch (Exception e) {
            logger.error("测试服务执行失败", e);
            // 抛出自定义业务异常，携带明确的错误码
            throw new BusinessException(ErrorCode.SYSTEM_ERROR.getCode(), "测试服务执行失败: " + e.getMessage());
        }
    }
}
